package com.example.swordjava;


public class Test49 {

    public static void main(String[] args) {

        int[][] a = {{1, 2, 3, 4},
                {5, 6, 7, 8},
                {9, 10, 11, 12},
                {13, 14, 15, 16}};

        System.out.println(Math.pow(1, 10));

    }

    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }
    }

    /**
     * 丑数
     * 把只包含质因子2、3和5的数称作丑数（Ugly Number）。例如6、8都是丑数，但14不是，因为它包含质因子7。
     * 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第 n个丑数。
     */

    public int GetUglyNumber_Solution(int index) {
        // write code here
        if (index <= 1) return index;
        int[] a = new int[index];
        a[0] = 1;
        int t2 = 0;
        int t3 = 0;
        int t5 = 0;

        for (int i = 1; i < index; i++) {
            int min = Math.min(Math.min(a[t2] * 2, a[t3] * 3), a[t5] * 5);
            //所有丑叔都是这三个数之一（多）的倍数
            if (min == a[t2] * 2) t2++;
            if (min == a[t3] * 3) t3++;
            if (min == a[t5] * 5) t5++;
            a[i] = min;
        }
        return a[index - 1];
    }

}














